package com.mars.ticket.controller;


import com.mars.ticket.request.SysTicketRequest;
import com.mars.ticket.response.result.R;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;

import com.mars.ticket.service.ITicketService;

/**
 * Ticket 控制层
 *
 * @Author wq
 * @Date 2021-03-15
 **/
@RestController
@RequestMapping("/ticket")
@AllArgsConstructor
public class TicketController {

    private final ITicketService ticketService;


    /**
     * 添加车票
     *
     * @param request request
     * @return R
     */
    @PostMapping("/add")
    public R add(@RequestBody SysTicketRequest request) {
        ticketService.add(request);
        return R.success();
    }

    /**
     * 删除车票
     *
     * @return R
     */
    @GetMapping("/delete")
    public R delete(Integer id) {
        ticketService.delete(id);
        return R.success();
    }

    /**
     * 查询车票
     *
     * @param id id
     * @return R
     */
    @GetMapping("/acquire")
    public R acquire(Integer id) {
        return R.success(ticketService.acquire(id));
    }

    /**
     * 修改车票
     *
     * @param request request
     * @return R
     */
    @PostMapping("/update")
    public R update(@RequestBody SysTicketRequest request) {
        ticketService.updateTicket(request);
        return R.success();
    }


    /**
     * 车票
     *
     * @param request request
     * @return R
     */
    @PostMapping("/list")
    public R listTicket(@RequestBody SysTicketRequest request) {
        return R.success(ticketService.listTicket(request));
    }




}